package com.tomtom.amelinium.backlogservice.model;

import java.util.ArrayList;

/**
 * Object model of the backlog.
 * 
 *  @author Natasza.Nowak@tomtom.com
 */
public class BacklogModel {

	/**
	 * Represents the text on the Confluence page before the BACKLOG marker (not
	 * to be parsed).
	 */
	private String intro = "";

	/**
	 * Sum of all the points burned in the backlog.
	 */
	private int overallBurnedStoryPoints = 0;

	/**
	 * List of projects in the backlog.
	 */
	private ArrayList<Project> projects = new ArrayList<Project>();
	
	private boolean dividedIntoProjects = false;

	public BacklogModel() {
		super();
		projects.add(new Project());
	}

	/**
	 * Concatenates a line to intro followed by new line.
	 */
	public void addLineToIntro(String line) {
		this.intro += line + "\n";
	}
	
	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public int getOverallBurnedStoryPoints() {
		return overallBurnedStoryPoints;
	}

	public void setOverallBurnedStoryPoints(int burnedStoryPoints) {
		this.overallBurnedStoryPoints = burnedStoryPoints;
	}

	public void addToBurnedStoryPoints(int burnedStoryPoints) {
		this.overallBurnedStoryPoints += burnedStoryPoints;
	}

	public ArrayList<Project> getProjects() {
		return projects;
	}

	public void setProjects(ArrayList<Project> projects) {
		this.projects = projects;
	}
	
	public Project getLastProject (){
		return projects.get(projects.size()-1);
	}
	public Project getFirstProject (){
		return projects.get(0);
	}

	public boolean isDividedIntoProjects() {
		return dividedIntoProjects;
	}

	public void setDividedIntoProjects(boolean dividedIntoProjects) {
		this.dividedIntoProjects = dividedIntoProjects;
	}

	public ArrayList<FeatureGroup> getFeatureGroupsFromAllProjects() {
		ArrayList<FeatureGroup> featureGroups = new ArrayList<FeatureGroup>();
		for (Project p : projects){
			for (FeatureGroup fg : p.getFeatureGroups()){
				featureGroups.add(fg);
			}
		}
		return featureGroups;
	}

}
